using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SmartSiteManagementSystem.IServices;
using SmartSiteManagementSystem.Models.Admin;

namespace SmartSiteManagementSystem.WorkerService
{
    public class Worker : BackgroundService
    {
        private readonly ILogger<Worker> _logger;

        private readonly IAdminService _adminService;

        public Worker(ILogger<Worker> logger, IAdminService adminService)
        {
            _logger = logger;
            _adminService = adminService;
        }

        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                AdminUserInfo adminUserInfo= _adminService.GetAdminUserInfoByUserId(1);
                _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
                await Task.Delay(1000, stoppingToken);
            }
        }
    }
}
